﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Reviewer.Entities.Services;
using Reviewer.Data;
using System.Web;
using Reviewer.Entities;
using System.Web.Caching;

namespace Reviewer.Business.Services
{
    internal class SystemTextService : BaseService, ISystemTextService, ISystemTextAdminService
    {
        internal SystemTextService() : base() { }

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }

        #region ISystemTextService Members

        public ICollection<SystemText> Find()
        {
            return new SystemTextRepository().SelectAll();
        }

        public SystemText Find(int id)
        {
            return new SystemTextRepository().SelectBy(id);
        }

        #endregion

        #region ISystemTextAdminService Members

        public void Delete(int id)
        {
            new SystemTextRepository().Delete(id);
        }

        public SystemText Save(SystemText text)
        {
            if (text.Id > 0)
            {
                return new SystemTextRepository().Update(text);
            }
            else
            {
                return new SystemTextRepository().Create(text);
            }
        }

        #endregion
    }
}
